package com.hanhai;


import java.util.*;

/**
 * @Author weijingchen
 * @Date 2025/6/4 22:30
 * @Version 1.0.0
 */
public class Day0604 {
    public static void main(String[] args) {
        Integer[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        Arrays.sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1 - o2;
            }
        });


        System.out.println(Arrays.toString(arr));


        //  lambda 表达式完整格式
        Arrays.sort(arr, (Integer o1, Integer o2) -> {
                    return o1 - o2;
                }
        );

        //  lambda 表达式省略写法
        Arrays.sort(arr, (o1, o2) -> o2 - o1);

        System.out.println(Arrays.toString(arr));
    }


    public static void iterator() {
        List<Integer> list = new ArrayList<>();

        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()) {
            Integer next = iterator.next();
            System.out.println(next);
        }


    }
}
